package in.muton.edushare.grading.panels.gradeDisplay;

import in.muton.edushare.grading.panels.studentGrades.GradingUtil;
import in.muton.edushare.grading.panels.studentGrades.GradingUtil.ItemGradeHelper;
import in.muton.edushare.pages.common.EdusharePanel;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.CourseInstances;
import com.edushare.common.vo.Users;

public class ItemView extends EdusharePanel {
	private static final long serialVersionUID = -8196359852269547441L;

	public ItemView(String id, final IModel<Users> userModel,
			final IModel<CourseInstances> courseModel) {
		super(id);
		GradingUtil gu = new GradingUtil(courseModel);
		add(new ListView<ItemGradeHelper>("itemGradeViewLV", gu
				.getGradesByUser(userModel.getObject())) {
			private static final long serialVersionUID = 5811170744555275650L;

			@Override
			protected void populateItem(ListItem<ItemGradeHelper> arg0) {
				ItemGradeHelper i = arg0.getModelObject();
				arg0.add(new Label("itemName", i.gradingItem.getObject()
						.getGradingItemName()));
				String marks = i.marks + " / "
						+ i.gradingItem.getObject().getMaxMarks()
						+ " ( Weightage : "
						+ i.gradingItem.getObject().getWeightage() + "%)";
				arg0.add(new Label("grade", marks));
			}
		});
	}
}
